##DATA Paper 2

use "C:\Users\Utente\OneDrive\Desktop\Ph.D\Tesi\Project\Data\Coding IT\Italian data with policy issues.dta", clear

##Logistic regression models to test hypothesis 1
##Model 0 (no interactions)
logit Fulfilment_2 GDP_change ib1.Issue Duration Npledgesparty, robust
##Model 1 (ref. category: economy)
logit Fulfilment_2 c.GDP_change##ib1.Issue Duration Npledgesparty, robust
##Figure 1 
margins r.Issue, at (GDP_change=(-1.5(0.5)2))
marginsplot, by (Issue) yline(0)
##Model 2 ((ref. category: social issue)
logit Fulfilment_2 c.GDP_change##ib2.Issue Duration Npledgesparty, robust
##Figure 2
margins r.ib2.Issue, at (GDP_change=(-1.5(0.5)2))
marginsplot, by (Issue) yline(0)

##Logistic regression models to test hypothesis 2a
##Model 3
logit Fulfilment_2 GDP_change welfareexp ib2.Partyfamily Duration Npledgesparty, robust
##Model 4
logit Fulfilment_2 c.GDP_change##i.welfareexp ib2.Partyfamily Duration Npledgesparty, robust
##Model 5
logit Fulfilment_2 GDP_change ib2.Partyfamily##i.welfareexp Duration Npledgesparty, robust
##Model 6
logit Fulfilment_2 c.GDP_change##ib2.Partyfamily##i.welfareexp Duration Npledgesparty, robust
##Figure 2
margins r.welfareexp, at (GDP_change=(-1.5(0.5)2) Partyfamily=(0 1 2))
marginsplot, by (Partyfamily) yline(0)

##Logistic regression models to test hypothesis 2b
##Model 7
logit Fulfilment_2 GDP_change economynonexp ib2.Partyfamily Duration Npledgesparty, robust
##Model 8
logit Fulfilment_2 c.GDP_change##i.economynonexp ib2.Partyfamily Duration Npledgesparty, robust
##Figure from model 8
margins r.economynonexp , at (GDP_change=(-1.5(0.5)2))
marginsplot, yline(0)
##Model 9
logit Fulfilment_2 GDP_change ib2.Partyfamily##i.economynonexp Duration Npledgesparty, robust
##Model 10
logit Fulfilment_2 c.GDP_change##ib2.Partyfamily##i.economynonexp Duration Npledgesparty, robust
##Figure from model 10
margins r.economynonexp, at (GDP_change=(-1.5(0.5)2) Partyfamily=(0 1 2))
marginsplot, by (Partyfamily) yline(0)


## Cross-tables
tab Fulfilment_2 economy, col, if GDP_change<0
tab Fulfilment_2 economynonexp , col, if GDP_change<0
tab Fulfilment_2 welfare , col, if GDP_change<0
tab Fulfilment_2 welfareexp , col, if GDP_change<0
tab Fulfilment_2 economy, col, if GDP_change>0
tab Fulfilment_2 economynonexp , col, if GDP_change>0
tab Fulfilment_2 welfare , col, if GDP_change>0
tab Fulfilment_2 welfareexp , col, if GDP_change>0
by Partyfamily, sort: tab Fulfilment_2 economy, col, if GDP_change<0
by Partyfamily, sort: tab Fulfilment_2 economynonexp , col, if GDP_change<0
by Partyfamily, sort: tab Fulfilment_2 welfare , col, if GDP_change<0
by Partyfamily, sort: tab Fulfilment_2 welfareexp , col, if GDP_change<0
by Partyfamily, sort: tab Fulfilment_2 economy, col, if GDP_change>0
by Partyfamily, sort: tab Fulfilment_2 economynonexp , col, if GDP_change>0
by Partyfamily, sort: tab Fulfilment_2 welfare , col, if GDP_change>0
by Partyfamily, sort: tab Fulfilment_2 welfareexp , col, if GDP_change>0


## Proportion test 
## to reject the null hypothesis (that the differences in the proportion of pledge fulfilled between the categories is = 0)
prtest Fulfilment_2, by (economy), if GDP_change<0 ## test the difference in the proportion of pledge fulfilled between economy=0 and economy=1
prtest Fulfilment_2, by (economy), if GDP_change>0
prtest Fulfilment_2, by (economynonexp), if GDP_change<0
prtest Fulfilment_2, by (economynonexp), if GDP_change>0
prtest Fulfilment_2, by (welfare), if GDP_change<0
prtest Fulfilment_2, by (welfare), if GDP_change>0
prtest Fulfilment_2, by (welfareexp), if GDP_change<0
prtest Fulfilment_2, by (welfareexp), if GDP_change>0

prtest Fulfilment_2, by (economy), if GDP_change<0 & Partyfamily==0
prtest Fulfilment_2, by (economy), if GDP_change<0 & Partyfamily==2
by Partyfamily, sort: prtest Fulfilment_2, by (economy), if GDP_change>0

prtest Fulfilment_2, by (economynonexp), if GDP_change<0 & Partyfamily==0
prtest Fulfilment_2, by (economynonexp), if GDP_change<0 & Partyfamily==2
by Partyfamily, sort:prtest Fulfilment_2, by (economynonexp), if GDP_change>0

prtest Fulfilment_2, by (welfare), if GDP_change<0 & Partyfamily==0
prtest Fulfilment_2, by (welfare), if GDP_change<0 & Partyfamily==2
by Partyfamily, sort: prtest Fulfilment_2, by (welfare), if GDP_change>0

prtest Fulfilment_2, by (welfareexp), if GDP_change<0 & Partyfamily==0
prtest Fulfilment_2, by (welfareexp), if GDP_change<0 & Partyfamily==2
by Partyfamily, sort: prtest Fulfilment_2, by (welfareexp), if GDP_change>0

prtest Fulfilment_2==.50 if GDP_change<0
prtest Fulfilment_2==.50 if GDP_change>0
prtest Fulfilment_2==.50 if GDP_change<0 & Partyfamily==0
prtest Fulfilment_2==.50 if GDP_change<0 & Partyfamily==2
prtest Fulfilment_2==.50 if GDP_change>0 & Partyfamily==0
prtest Fulfilment_2==.50 if GDP_change>0 & Partyfamily==2

##Robusteness tests
##Model 1 and 2 excluding 2013 election
logit Fulfilment_2 c.GDP_change##ib1.Issue Duration Npledgesparty, robust, if Election!=2013
logit Fulfilment_2 c.GDP_change##ib2.Issue Duration Npledgesparty, robust, if Election!=2013

